package extration;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;

public class ModeleBinomial extends Modele{
	
	
	
	public ModeleBinomial(Data d){
		data = d;
		System.out.println(EPSILON);
	}
	
	
	//Parametre binomial
	public void parametreBinomial(){
		mapPos= new HashMap<Mot,Float>();
		mapNeg = new HashMap<Mot,Float>();
		mapNeu = new HashMap<Mot,Float>();
		mapIrr = new HashMap<Mot,Float>();
		Float nb = 0.0f;
		for(Mot mot : apprentissage){
			for(Entry<String,Integer>  entry: mot.getNbMsgPolarite().entrySet()){
				String p = entry.getKey();
				int nbMsg = entry.getValue();
				int nbMsgTotPolarite = data.getPolarite().get(p).getMessages().size();
				nb = (float) nbMsg/(float) nbMsgTotPolarite;
				if(nb ==1){
					nb = 1-EPSILON;
				}
				else if(nb == 0){
					nb = EPSILON;
				}
				if(p.equals(Data.POSITIVE))
					this.mapPos.put(mot, nb);
				if(p.equals(Data.NEGATIVE))
					this.mapNeg.put(mot, nb);
				if(p.equals(Data.NEUTRAL))
					this.mapNeu.put(mot, nb);
				if(p.equals(Data.IRRELEVANT))
					this.mapIrr.put(mot, nb);
			}
		}
	}
	
	
	

	

}
